<template>
	<view class="xb-page">
		<view  class="xb-textbutton-cell"><view @click="addsubject" class="xb-textbutton  page-button-right">添加新科目</view></view>
		<view class="xb-list" >
			<view class="xb-list-cell" v-for="(subject ,index) in subjctlist" :key="index">
				<view class="xb-list-cell-navigate">
					{{subject.name}}
				</view>
			</view>
		</view>
	          </view>
</template>

<script>
import pageHead from '../../../components/page-head.vue';
import { subjectlist } from '../../../api/getData.js';
export default {
    onLoad(option){
        this.initData();
    },
     onPullDownRefresh() {
       this.initData();
    },
    data() {
        return {
            formdata: {
                pageno: 1,
                pagesize: 10,
            },
            subjctlist: [
                {
                    name: '语文'
                },
                {
                    name: '数学'
                },
								{
										name: '英语'
								}
            ]
        };
    },
    onLoad: function(option) {
        	//this.initdata();
    },
    onPullDownRefresh: function() {
        //initdata();
    },
    methods: {
			addsubject:function(){
				uni.navigateTo({
					url:'addsubject'
				})
			},
        initdata: async function(e) {
            uni.startPullDownRefresh();
            const res =  await subjectlist(this.formdata);
            if (res.success == true) {
                this.formdata.pageno++;
            } else {
                console.error(e);
            }
            uni.stopPullDownRefresh();
        }
    }
};
</script>

<style scoped >
@import '../../../common/uni.css';
@import '../../../common/xb.css';
.page-button-right {
	position: absolute;
	right: 3%;
	top:30%;
}

</style>
